package com.come4loves.game.module.fight.action;

import com.come4loves.game.module.battle.helper.PBConvertHelper;
import com.come4loves.game.module.fight.model.BuffData;
import com.come4loves.game.module.fight.model.FightCard;
import com.come4loves.game.proto.BattleProto;
import com.google.protobuf.GeneratedMessage.Builder;

public class BuffAction extends Action {
	private BuffData buffData;
	private int state;
	public BuffAction(FightCard fightCard,BuffData buffData, int state) {
		super(fightCard.getId());
		if (buffData == null) {
			throw new RuntimeException("BuffData null");
		}
		this.buffData = buffData;
		this.state = state;
	}
	
	public int getState() {
		return state;
	}
	
	public BuffData getBuffData() {
		return buffData;
	}

	@Override
	public Builder<?> toProtocolBufferBuilder() {
		BattleProto.BuffAction.Builder builder = BattleProto.BuffAction.newBuilder();
		BattleProto.BuffData.Builder builder1 = BattleProto.BuffData.newBuilder();
		builder.setId((int) this.id);
		builder1.setBuffType(PBConvertHelper.buffTypeConvert(this.buffData.getBuffType()));
		builder1.setBuffValue(this.buffData.getBuffValue());
		builder.setBuffData(builder1);
		builder.setBuffState(this.state);
		return builder;
	}

}
